[#escape x as (x)!?html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>忘记密码_${site.fullNameOrName}</title>
	<script language="javascript" type="text/javascript" src="${fore}/jquery.js"></script>
	<script language="javascript" type="text/javascript" src="${fore}/bluewise.js"></script>
	<script language="javascript" type="text/javascript" src="${fore}/fore.js"></script>
	<script language="javascript" type="text/javascript" src="_files/common.js"></script>
	<script language="javascript" type="text/javascript" src="${fore}/jquery.validation_zh_CN.js"></script>
	<link href="_files/css/base.css" type="text/css" rel="stylesheet"/>
	<style type="text/css">
		.error {
			color: #ff0000
		}
	</style>
	<script type="text/javascript">
		$(function () {

			$.validator.addMethod("username", function (value) {
				if (value.length == 0) {
					return true;
				}
				var p = /${global.register.validCharacter}/;
				return p.exec(value) ? true : false;
			}, "用户名必须是字母、数字和汉字");
			$("#validForm").validate({
				rules: {
					mobile: {required: true},
					verifycode: {required: true},
					email: {required: true, email: true},
					password: {required: true},
					password_repeat: {required: true, equalTo: "input[name='password']"},
					realname: {required: true},
					hospital: {required: true},
					sel_are: {required: true}
				},
				messages: {
					mobile: {required: "手机号必填"},
					verifycode: {required: "验证码必填"},
					email: {required: "必填", email: "电邮错误"},
					password: {required: "必填"},
					password_repeat: {required: "必填", equalTo: "两次密码不同"},
					realname: {required: "必填"},
					hospital: {required: "必填"},
					sel_are: {required: "必填"}
				},
				submitHandler: function (form) {
					$.ajax({
						data: $(form).serialize(),
						type: "POST",
						url: "/registerAjax.jspx",
						contentType: "application/x-www-form-urlencoded;",
						dataType: 'json',
						success: function (response, textStatus, jqXHR) {
							alert(response.message);
							if (response.code >= 0) {
								window.location.href = '/login.jspx';
							}
						},
						error: function (xhr, textStatus, errorThrown) {
							alert(errorThrown);
						}
					});
					return false;
				}
			});
		});

	</script>
</head>
<body>
<div class="tbanner">
	<h1>珍医网</h1>

	<div class="tbanpic"><img src="_files/img/ban.jpg" width="722" height="100"/></div>
</div>
<div class="loginmain">
	<span class="t"></span><span class="b"></span>

	<div class="logtit">找回密码</div>
	<div class="logl">
		<div class="zclcon">


			<form id="validForm" action="${ctx}/forgot_password.jspx" method="post">
				<div class="tabcon" id="formcontent">
					<input type="hidden" name="mode" value="${mode}"/>
					<div class="framp"  style="width: 550px">
						<label style="width: 150px">用户名/手机号/EMAIL：</label>
						<input name="id" type="text" class="txt1"/> &nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:sendPasswordCode()">发送验证码</a>
					</div>
					<div class="framp"  style="width: 550px">
						<label style="width: 150px">接收到的验证码：</label>
						<input name="password_code" type="text" class="txt1"/>
					</div>
					<div class="framp"  style="width: 550px">
						<label style="width: 150px">新密码：</label>
						<input name="password" type="password" class="txt1"/>
					</div>
					<div class="framp"  style="width: 550px">
						<label style="width: 150px">确认密码：</label>
						<input name="password_repeat" type="password" class="txt1"/>
					</div>
					<div class="framp"  style="width: 550px">
						<input name="register" type="button" class="fbtn" onclick="return resetPassword()" value="重置密码"/>
					</div>
				</div>
			</form>
		</div>

	</div>

</div>
[#include 'inc_footer.html'/]
<script type="text/javascript">

	function sendPasswordCode() {
		var id = $("[name='id']").val();
		if ($.trim(id) == '') {
			alert("用户名/邮箱/手机号不能为空");
			return;
		}
		$.ajax({
			type: "GET",
			url: "/register/send.jspx",
			data: "id=" + id,
			success: function (json) {
				alert(json.message);
			}
		})
	}

	function resetPassword() {
		var id = $.trim($("[name='id']").val());
		var password_code = $.trim($("[name='password_code']").val());
		var password = $.trim($("[name='password']").val());
		var password_repeat = $.trim($("[name='password_repeat']").val());
		if (id == "") {
			alert("用户名/邮箱/手机号不能为空");
			return;
		}
		if (password_code == "" || password_code.length != 6) {
			alert('验证码不能为空或长度不正确');
			return;
		}
		if (password == "") {
			alert('新密码不能为空');
			return;
		}
		if (password != password_repeat) {
			alert('两次密码不同');
			return;
		}
		$.ajax({
			type: "POST",
			url: "/forgot_password.jspx",
			data: $("#validForm").serialize(),
			success: function (json) {
				alert(json.message);
				if (json.code > 0) {
					window.location.href = '/login.jspx';
				}
			}
		})
	}
</script>
</body>
</html>

[/#escape]